<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon.ico?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon.ico?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="HTML,">










<meta name="description" content="1.对HTML语义化的理解 HTML语义化就是让页面内容结构化，便于浏览器、搜索引擎解析 在没有css样式的时候也是一种文档格式，便于阅读 搜索引擎的爬虫依赖于标记来确定上下文和各个关键字的权重，利于SEO 使阅读源码的人对网站有一个更加清晰的分块，便于阅读理解  2.子元素垂直水平居中的实现方式 子元素宽高不知道     123&amp;lt;div class=&quot;box1&quot;&amp;gt;    &amp;lt;di">
<meta name="keywords" content="HTML">
<meta property="og:type" content="article">
<meta property="og:title" content="html-css-基础">
<meta property="og:url" content="http://zhanglei_c.gitee.io/blog/2019/10/08/html-css-基础/index.html">
<meta property="og:site_name" content="爱吃零食的猫">
<meta property="og:description" content="1.对HTML语义化的理解 HTML语义化就是让页面内容结构化，便于浏览器、搜索引擎解析 在没有css样式的时候也是一种文档格式，便于阅读 搜索引擎的爬虫依赖于标记来确定上下文和各个关键字的权重，利于SEO 使阅读源码的人对网站有一个更加清晰的分块，便于阅读理解  2.子元素垂直水平居中的实现方式 子元素宽高不知道     123&amp;lt;div class=&quot;box1&quot;&amp;gt;    &amp;lt;di">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2019-10-30T14:52:27.200Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="html-css-基础">
<meta name="twitter:description" content="1.对HTML语义化的理解 HTML语义化就是让页面内容结构化，便于浏览器、搜索引擎解析 在没有css样式的时候也是一种文档格式，便于阅读 搜索引擎的爬虫依赖于标记来确定上下文和各个关键字的权重，利于SEO 使阅读源码的人对网站有一个更加清晰的分块，便于阅读理解  2.子元素垂直水平居中的实现方式 子元素宽高不知道     123&amp;lt;div class=&quot;box1&quot;&amp;gt;    &amp;lt;di">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://zhanglei_c.gitee.io/blog/2019/10/08/html-css-基础/">





  <title>html-css-基础 | 爱吃零食的猫</title>
  








</head>

<script type="text/javascript" color="0,0,255" opacity="0.7" zindex="-2" count="99" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
<a href="https://github.com/403NotFound" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewbox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">爱吃零食的猫</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">自由，平等，公正，法治</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/blog/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://zhanglei_c.gitee.io/blog/blog/2019/10/08/html-css-基础/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Zhang_lei">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱吃零食的猫">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">html-css-基础</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-10-08T22:49:52+08:00">
                2019-10-08
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h4 id="1-对HTML语义化的理解"><a href="#1-对HTML语义化的理解" class="headerlink" title="1.对HTML语义化的理解"></a>1.对HTML语义化的理解</h4><ul>
<li>HTML语义化就是让页面内容结构化，便于浏览器、搜索引擎解析</li>
<li>在没有css样式的时候也是一种文档格式，便于阅读</li>
<li>搜索引擎的爬虫依赖于标记来确定上下文和各个关键字的权重，利于SEO</li>
<li>使阅读源码的人对网站有一个更加清晰的分块，便于阅读理解</li>
</ul>
<h4 id="2-子元素垂直水平居中的实现方式"><a href="#2-子元素垂直水平居中的实现方式" class="headerlink" title="2.子元素垂直水平居中的实现方式"></a>2.子元素垂直水平居中的实现方式</h4><ul>
<li><p>子元素宽高不知道    </p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"box1"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/************方案一*****************/</span></span><br><span class="line"><span class="selector-class">.box1</span> &#123;</span><br><span class="line">    <span class="attribute">position</span>: relative;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.box1</span> <span class="selector-tag">div</span> &#123;</span><br><span class="line">    <span class="attribute">position</span>: absolute;</span><br><span class="line">    <span class="attribute">top</span>: <span class="number">50%</span>;</span><br><span class="line">    <span class="attribute">left</span>: <span class="number">50%</span>;</span><br><span class="line">    <span class="comment">/*transform:translate(x,y)括号的百分比数据，会以本身的长宽做参考*/</span></span><br><span class="line">    <span class="attribute">transform</span>: <span class="built_in">translate</span>(-50%,-50%);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/************方案二*****************/</span></span><br><span class="line"><span class="selector-class">.box1</span> &#123;</span><br><span class="line">    <span class="attribute">position</span>: relative;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.box1</span> <span class="selector-tag">div</span> &#123;</span><br><span class="line">    <span class="attribute">position</span>: absolute;</span><br><span class="line">    <span class="attribute">left</span>: <span class="number">0</span>;</span><br><span class="line">    <span class="attribute">top</span>: <span class="number">0</span>;</span><br><span class="line">    <span class="attribute">right</span>: <span class="number">0</span>;</span><br><span class="line">    <span class="attribute">bottom</span>: <span class="number">0</span>;</span><br><span class="line">    <span class="attribute">margin</span>: auto;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/************方案三*****************/</span></span><br><span class="line"><span class="selector-class">.box1</span> &#123;</span><br><span class="line">    <span class="attribute">display</span>: flex;</span><br><span class="line">    <span class="attribute">justify-content</span>: center;</span><br><span class="line">    <span class="attribute">align-items</span>: center;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/************方案四*****************/</span></span><br><span class="line"><span class="selector-class">.box1</span> &#123;</span><br><span class="line">    <span class="attribute">display</span>: table-cell;</span><br><span class="line">    <span class="attribute">vertical-align</span>: middle;</span><br><span class="line">    <span class="attribute">text-align</span>: center;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.box1</span> <span class="selector-tag">div</span> &#123;</span><br><span class="line">    <span class="attribute">display</span>: inline-block;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<ul>
<li><p>子元素宽高知道(上述方案同样适用)</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"box1"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/************方案一*****************/</span></span><br><span class="line"><span class="selector-class">.box1</span> &#123;</span><br><span class="line">    <span class="attribute">position</span>: relative;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-class">.box1</span> <span class="selector-tag">div</span> &#123;</span><br><span class="line">    <span class="attribute">width</span>: <span class="number">100px</span>;</span><br><span class="line">    <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line">    <span class="attribute">position</span>: absolute;</span><br><span class="line">    <span class="attribute">top</span>: <span class="number">50%</span>;</span><br><span class="line">    <span class="attribute">left</span>: <span class="number">50%</span>;</span><br><span class="line">    <span class="attribute">margin-top</span>: -<span class="number">50px</span>;<span class="comment">/*负的高度的一半*/</span></span><br><span class="line">    <span class="attribute">margin-left</span>: -<span class="number">50px</span>;<span class="comment">/*负的宽度的一半*/</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h4 id="3-css选择器-gt-空格-的区别"><a href="#3-css选择器-gt-空格-的区别" class="headerlink" title="3.css选择器 .  #   &gt;  空格  ,  + 的区别"></a>3.css选择器 <code>.</code>  <code>#</code>   <code>&gt;</code>  <code>空格</code>  <code>,</code>  <code>+</code> 的区别</h4><ul>
<li><p>class选择器<code>.</code>  和 id选择器 <code>#</code></p>
<blockquote>
<p>相同的class选择器在html中可以出现多次，但是id选择器只能出现一次</p>
</blockquote>
</li>
<li><p>空格选择器</p>
<blockquote>
<p>空格选择器是后代选择器 ，包括儿子，孙子，…,只要是后代都会被选中</p>
</blockquote>
</li>
<li><p><code>&gt;</code>  子代选择器</p>
<blockquote>
<p>只能选择它的儿子</p>
</blockquote>
</li>
<li><p>兄弟选择器<code>+</code></p>
<blockquote>
<p><code>+</code>是离自己最近的兄弟选择器，只能选择自己下一个兄弟标签</p>
</blockquote>
</li>
<li><p>多个选择器<code>,</code></p>
<blockquote>
<p><code>,</code>是多个选择器，他们可以共用同一个样式</p>
</blockquote>
</li>
</ul>
<h4 id="4-BFC（块格式化上下文-Block-Formatting-Context-）"><a href="#4-BFC（块格式化上下文-Block-Formatting-Context-）" class="headerlink" title="4.BFC（块格式化上下文 Block Formatting Context ）"></a>4.BFC（块格式化上下文 Block Formatting Context ）</h4><blockquote>
<p>不要试图去解释BFC的定义，我们只需要知道它的特性就好了，BFC只有特性，“没有定义”</p>
<blockquote>
<p>特性：</p>
<ul>
<li>使BFC内部元素不会到处乱跑(浮动元素会脱离文档流，为了让他不脱离文档流就要产生BFC)</li>
<li>和浮动元素产生边界</li>
</ul>
</blockquote>
</blockquote>
<ul>
<li><p>MDN 官方解释</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">    一个块格式化上下文（block formatting context） 是Web页面的可视化CSS渲染出的一部分。它是块级盒布局出现的区域，也是浮动层元素进行交互的区域。</span><br><span class="line">一个块格式化上下文由以下之一创建：</span><br><span class="line"></span><br><span class="line">根元素或其它包含它的元素</span><br><span class="line">	浮动元素 (元素的 float 不是 none)</span><br><span class="line">	绝对定位元素 (元素具有 position 为 absolute 或 fixed)</span><br><span class="line">	内联块 (元素具有 display: inline-block)</span><br><span class="line">	表格单元格 (元素具有 display: table-cell，HTML表格单元格默认属性)</span><br><span class="line">	表格标题 (元素具有 display: table-caption, HTML表格标题默认属性)</span><br><span class="line">	具有overflow 且值不是 visible 的块元素，</span><br><span class="line">	display: flow-root</span><br><span class="line">	column-span: all 应当总是会创建一个新的格式化上下文，即便具有 column-span: all 的元素并不被包	裹在一个多列容器中。</span><br><span class="line">    一个块格式化上下文包括创建它的元素内部所有内容，除了被包含于创建新的块级格式化上下文的后代元素内的元素。</span><br><span class="line">    块格式化上下文对于定位 (参见 float) 与清除浮动 (参见 clear) 很重要。定位和清除浮动的样式规则只适用于处于同一块格式化上下文内的元素。浮动不会影响其它块格式化上下文中元素的布局，并且清除浮动只能清除同一块格式化上下文中在它前面的元素的浮动。</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h4 id="5-对H5的理解"><a href="#5-对H5的理解" class="headerlink" title="5.对H5的理解"></a>5.对H5的理解</h4><ul>
<li>优点<ul>
<li>多设备，跨平台</li>
<li>标签语义化，可读性高</li>
<li>提供了更多的多媒体元素（视频和音频）</li>
<li>很好的替代了Flash 和 <a href="https://baike.baidu.com/item/Microsoft%20SilverLight/3466480?fromtitle=silverlight&amp;fromid=4088479&amp;fr=aladdin" target="_blank" rel="noopener">Microsoft Silverlight</a></li>
<li>涉及到网站抓取和索引的时候，更利于SEO</li>
<li>可被大量应用于移动应用程序和游戏</li>
<li>可移植性好</li>
</ul>
</li>
<li>缺点<ul>
<li>安全性差，web storage 和 web socket很容易被黑客利用</li>
<li>兼容性差</li>
<li>未被大多数浏览器很好的支持，用户体验不佳</li>
</ul>
</li>
</ul>
<h4 id="6-CSS3动画"><a href="#6-CSS3动画" class="headerlink" title="6. CSS3动画"></a>6. CSS3动画</h4><ul>
<li><p>过渡动画 <code>transition</code></p>
<ul>
<li>从初始状态到结束状态这个过程所产生的的动画。所谓状态就是指大小，位置，颜色，变形（transform）等属性。css 过渡只能定义首尾两个状态。</li>
</ul>
</li>
<li><p>关键帧动画 <code>keyframes</code></p>
<ul>
<li><p>不同于第一种过渡动画只能定义首尾两个状态，关键帧动画可以定义多个状态，所以可以实现很多复杂的动画效果</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="attribute">width</span>:<span class="number">100px</span>;</span><br><span class="line">	<span class="attribute">height</span>:<span class="number">100px</span>;</span><br><span class="line">	<span class="attribute">background</span>:red;</span><br><span class="line">	<span class="attribute">position</span>:relative;</span><br><span class="line">	<span class="attribute">animation</span>:mymove <span class="number">5s</span> infinite;</span><br><span class="line">	<span class="attribute">-webkit-animation</span>:mymove <span class="number">5s</span> infinite; <span class="comment">/* Safari and Chrome */</span></span><br><span class="line">&#125;</span><br><span class="line">@<span class="keyword">keyframes</span> mymove</span><br><span class="line">&#123;</span><br><span class="line">	0%   &#123;<span class="attribute">top</span>:<span class="number">0px</span>; <span class="attribute">left</span>:<span class="number">0px</span>; <span class="attribute">background</span>:red;&#125;</span><br><span class="line">	25%  &#123;<span class="attribute">top</span>:<span class="number">0px</span>; <span class="attribute">left</span>:<span class="number">100px</span>; <span class="attribute">background</span>:blue;&#125;</span><br><span class="line">	50%  &#123;<span class="attribute">top</span>:<span class="number">100px</span>; <span class="attribute">left</span>:<span class="number">100px</span>; <span class="attribute">background</span>:yellow;&#125;</span><br><span class="line">	75%  &#123;<span class="attribute">top</span>:<span class="number">100px</span>; <span class="attribute">left</span>:<span class="number">0px</span>; <span class="attribute">background</span>:green;&#125;</span><br><span class="line">	100% &#123;<span class="attribute">top</span>:<span class="number">0px</span>; <span class="attribute">left</span>:<span class="number">0px</span>; <span class="attribute">background</span>:red;&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
</li>
</ul>
<h4 id="7-css-引入方式优先级"><a href="#7-css-引入方式优先级" class="headerlink" title="7.css 引入方式优先级"></a>7.css 引入方式优先级</h4><blockquote>
<p>行内 &gt; 内嵌 &gt; 链接 &gt; 导入</p>
</blockquote>
<h4 id="8-rem-和-px"><a href="#8-rem-和-px" class="headerlink" title="8. rem 和 px"></a>8. <code>rem</code> 和 <code>px</code></h4><ul>
<li><p>rem</p>
<blockquote>
<p>rem 是 css3 新增的一个相对长度单位，他只想对于根目录（html元素）,一般用来做手机端的适配</p>
<p>例： </p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">&gt; <span class="selector-tag">html</span> &#123;</span><br><span class="line">&gt;     font-size: 20px; /* 1rem = 20px */</span><br><span class="line">&gt; &#125;</span><br><span class="line">&gt; <span class="selector-tag">html</span> &#123;</span><br><span class="line">&gt;     font-size: 30px; /* 1rem = 30px */</span><br><span class="line">&gt; &#125;</span><br><span class="line">&gt;</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>px</p>
<blockquote>
<p>像素，固定大小单元，一个像素等于屏幕上的一个点（当前屏幕的最小分割）。PC 端默认字体大小为16px</p>
</blockquote>
</li>
</ul>
<h4 id="9-link-和-import的区别"><a href="#9-link-和-import的区别" class="headerlink" title="9.link 和 @import的区别"></a>9.<code>link</code> 和 <code>@import</code>的区别</h4><ul>
<li><p>从属关系区别</p>
<blockquote>
<p><code>@import</code>是css提供的语法规则，只有导入样式表的作用; <code>link</code>是HTML提供的标签，不仅可以加载css文件，还可以定义<code>rel(rel 属性规定当前文档与被链接文档之间的关系。)</code>链接属性等</p>
<blockquote>
<p><code>rel</code>属性值一览</p>
</blockquote>
<p>| alternate  | 文档的替代版本（比如打印页、翻译或镜像）。 |<br>| ———- | —————————————— |<br>| stylesheet | 文档的外部样式表。                         |<br>| start      | 集合中的第一个文档。                       |<br>| next       | 集合中的下一个文档。                       |<br>| prev       | 集合中的上一个文档。                       |<br>| contents   | 文档的目录。                               |<br>| index      | 文档的索引。                               |<br>| glossary   | 在文档中使用的词汇的术语表（解释）。       |<br>| copyright  | 包含版权信息的文档。                       |<br>| chapter    | 文档的章。                                 |<br>| section    | 文档的节。                                 |<br>| subsection | 文档的小节。                               |<br>| appendix   | 文档的附录。                               |<br>| help       | 帮助文档。                                 |<br>| bookmark   | 相关文档。                                 |</p>
</blockquote>
</li>
<li><p>加载顺序区别</p>
<blockquote>
<p>加载页面时，<code>link</code>标签引入的 css 同时被加载；<code>@import</code>引入的css将在页面加载完毕后被加载</p>
</blockquote>
</li>
<li><p>兼容性区别</p>
<blockquote>
<p><code>@import</code>是css2.1以后才有的语法，所以只有IE5+以上的浏览器才能被识别；<code>link</code>标签作为html元素，不存在兼容性问题</p>
</blockquote>
</li>
<li><p>DOM可控性区别</p>
<blockquote>
<p><code>link</code>支持JavaScript控制DOM去改变样式；<code>@import</code>不支持</p>
</blockquote>
</li>
</ul>
<h4 id="10-CSS-Reset-的作用和用途"><a href="#10-CSS-Reset-的作用和用途" class="headerlink" title="10.CSS Reset 的作用和用途"></a>10.CSS Reset 的作用和用途</h4><blockquote>
<p>每个浏览器都会有一些自带的或者公有的默认样式，会造成布局上的一些困扰，css reset 的作用就是消除这些默认样式，使样式表现一致；也为了页面能实现跨浏览器的兼容性，所以有时候需要引入一些css重置文件去覆盖浏览器默认的样式</p>
</blockquote>
<h4 id="11-CSS-Sprites-如何使用和他的优点是什么"><a href="#11-CSS-Sprites-如何使用和他的优点是什么" class="headerlink" title="11.CSS Sprites 如何使用和他的优点是什么"></a>11.CSS Sprites 如何使用和他的优点是什么</h4><ul>
<li>css sprites(css 精灵) 就是把一堆小图片整合到一张大图片上，从而减轻服务器对图片的请求数量</li>
<li>优点<ul>
<li>减少了图片数量，减少了http请求数，减小了服务器负担</li>
<li>整个图片变小了，图片下载速度更快</li>
<li>不使用JavaScript代码，纯CSS 就可以</li>
</ul>
</li>
</ul>
<h4 id="12-为何要使用translate-而不是position-absolute，理由是什么"><a href="#12-为何要使用translate-而不是position-absolute，理由是什么" class="headerlink" title="12.为何要使用translate()而不是position:absolute，理由是什么"></a>12.为何要使用<code>translate()</code>而不是<code>position:absolute</code>，理由是什么</h4><blockquote>
<p>两者都是相对于自身进行移动</p>
</blockquote>
<ul>
<li>当元素原来已经有 <code>position:absolute</code>  时，此时你想要相对于自身移动，可以使用<code>translate</code></li>
<li><code>translate</code>更适合动画，因为不会引起重绘和重排</li>
<li><code>translate</code>可以调用系统自身的GPU加速，提高浏览器性能，但是过多的触发会严重导致性能问题，增加了内存使用（移动端不建议使用3D translate3d加速,会导致移动端电池寿命减少）</li>
</ul>
<blockquote>
<p>所以<code>translate</code>更适合动画，<code>position</code>一般用来布局</p>
</blockquote>
<h4 id="13-CSS处理背景透明度，文字透明与否"><a href="#13-CSS处理背景透明度，文字透明与否" class="headerlink" title="13. CSS处理背景透明度，文字透明与否"></a>13. CSS处理背景透明度，文字透明与否</h4><ul>
<li>背景与文字都透明</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">opcity</span>: <span class="selector-class">.5</span></span><br></pre></td></tr></table></figure>
<ul>
<li>背景透明，文字不透明</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">background</span>: <span class="selector-tag">rgba</span>(0,0,0,0<span class="selector-class">.5</span>)</span><br></pre></td></tr></table></figure>
<h4 id="14-什么是置换元素"><a href="#14-什么是置换元素" class="headerlink" title="14. 什么是置换元素"></a>14. 什么是置换元素</h4><blockquote>
<p> 置换元素的意思是 展现不是由CSS来控制的元素。这些外部元素的展现不依赖于CSS规范 </p>
<p>置换元素：浏览器根据元素的标签和属性，来决定元素的具体显示内容。<br>例如：浏览器会根据<code>&lt;img&gt;</code>标签的src属性的 值来读取图片信息并显示出来，而如果查看html代码，则看不到图片的实际内容；<code>&lt;input&gt;</code>标签的type属性来决定是显示输入 框，还是单选按钮等。 html中 的<code>&lt;img&gt;</code>、<code>&lt;input&gt;</code>、<code>&lt;textarea&gt;</code>、<code>&lt;select&gt;</code>、<code>&lt;object&gt;</code> 都是置换元素。这些元素往往没有实际的内容，即是一个空元素。</p>
<p>置换元素在其显示中生成了框，这也就是有的内联元素能够设置宽高的原因。</p>
</blockquote>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/blog/tags/HTML/" rel="tag"># HTML</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2019/10/08/一些面试题/" rel="next" title="一些面试题">
                <i class="fa fa-chevron-left"></i> 一些面试题
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2019/10/14/Hexo和Git配置/" rel="prev" title="Hexo和Git配置">
                Hexo和Git配置 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Zhang_lei</p>
              <p class="site-description motion-element" itemprop="description">爱吃零食的猫</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">43</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/blog/tags/index.html">
                  <span class="site-state-item-count">22</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/403NotFound" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.zhihu.com/people/ai-chi-bao-mi-hua-de-mao/activities" target="_blank" title="知乎">
                      
                        <i class="fa fa-fw fa-send"></i>知乎</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://gitee.com/ZhangLei_c" target="_blank" title="码云">
                      
                        <i class="fa fa-fw fa-github-alt"></i>码云</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://weibo.com/5205419998/profile?rightmod=1&wvr=6&mod=personinfo&is_all=1" target="_blank" title="weibo">
                      
                        <i class="fa fa-fw fa-weibo"></i>weibo</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-对HTML语义化的理解"><span class="nav-number">1.</span> <span class="nav-text">1.对HTML语义化的理解</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-子元素垂直水平居中的实现方式"><span class="nav-number">2.</span> <span class="nav-text">2.子元素垂直水平居中的实现方式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-css选择器-gt-空格-的区别"><span class="nav-number">3.</span> <span class="nav-text">3.css选择器 .  #   &gt;  空格  ,  + 的区别</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4-BFC（块格式化上下文-Block-Formatting-Context-）"><span class="nav-number">4.</span> <span class="nav-text">4.BFC（块格式化上下文 Block Formatting Context ）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-对H5的理解"><span class="nav-number">5.</span> <span class="nav-text">5.对H5的理解</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#6-CSS3动画"><span class="nav-number">6.</span> <span class="nav-text">6. CSS3动画</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#7-css-引入方式优先级"><span class="nav-number">7.</span> <span class="nav-text">7.css 引入方式优先级</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#8-rem-和-px"><span class="nav-number">8.</span> <span class="nav-text">8. rem 和 px</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#9-link-和-import的区别"><span class="nav-number">9.</span> <span class="nav-text">9.link 和 @import的区别</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#10-CSS-Reset-的作用和用途"><span class="nav-number">10.</span> <span class="nav-text">10.CSS Reset 的作用和用途</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#11-CSS-Sprites-如何使用和他的优点是什么"><span class="nav-number">11.</span> <span class="nav-text">11.CSS Sprites 如何使用和他的优点是什么</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#12-为何要使用translate-而不是position-absolute，理由是什么"><span class="nav-number">12.</span> <span class="nav-text">12.为何要使用translate()而不是position:absolute，理由是什么</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#13-CSS处理背景透明度，文字透明与否"><span class="nav-number">13.</span> <span class="nav-text">13. CSS处理背景透明度，文字透明与否</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#14-什么是置换元素"><span class="nav-number">14.</span> <span class="nav-text">14. 什么是置换元素</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Zhang_lei</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>


<div>
<span id="busuanzi_container_site_pv">
  本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>
<span id="busuanzi_container_site_uv">
    有<span id="busuanzi_value_site_uv"></span>人看过我的博客啦
</span>
</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/blog/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
